package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.QrCodeBean;
import com.qf.flash.mvp.contract.MyInvitationContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseResponse;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

public class MyInvitationPresenter extends BasePresenter<MyInvitationContract.View> implements MyInvitationContract.Presenter {
    @Override
    public void getQRCode() {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .MY_QRCODE(uid)
                .compose(RxUtils.handleBaseResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<BaseResponse<QrCodeBean>>(mRootView) {
                    @Override
                    public void onSuccess(BaseResponse<QrCodeBean> response) {
                        mRootView.showQrCode(response.getData());
                    }
                })
        );
    }
}
